<?php
include_once("conexionBD.php");

function anadirCita($cita) {
	verbindung();
	$texto = htmlentities($_POST['texto'], ENT_QUOTES);
	$select = mysql_query("SELECT MAX(SID) FROM `nt_aleatoria` ")or die(mysql_error());
	$row = mysql_fetch_array($select);
	$numero =  $row['MAX(SID)'];	
	$numero++;
	$nothing = "nothing";
	$select = mysql_query("INSERT INTO `nt_aleatoria` ( `SID` , `campo` , `texto` ) VALUES ('{$numero}', '{$nothing}','{$cita}' )") or die(mysql_error());
	desconectar();
}

function eliminarCita($cita) {
	verbindung();

	$select = mysql_query("DELETE FROM nt_aleatoria WHERE SID=".$cita."") or die(mysql_error());

desconectar();
}
function recogeCitas() {
  verbindung();
  $select = mysql_query("SELECT * FROM nt_aleatoria ORDER BY SID ASC") or die(mysql_error());

desconectar();
  return $select;	
}

function modificarCita($cita, $citaAntigua) {
verbindung();
  $select = mysql_query("UPDATE nt_aleatoria SET texto='".$cita."' WHERE texto='".$citaAntigua."'") or die("error mysql");
 desconectar();
  return $select;	
}

?>